package org.acompanhamento.domain;

import static javax.persistence.FetchType.LAZY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Index;

import org.hibernate.validator.NotNull;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;

/**
 * 
 * @author icaro.kume
 *
 */
@Entity
@Table(name = "STATUS")
@Alias("STATUS")
@Documentation("STATUS")
@SequenceGenerator(name = "SEQ_STATUS", sequenceName = "SEQ_STATUS")
public class Status extends PersistableBusinessObject {

	private Long id;

	private String name;

	private Workflow workflow;

	@Id
	@GeneratedValue(generator = "SEQ_STATUS")
	@Column(name = "COD_STATUS", nullable = false)
	@Documentation("STATUS ID")
	public Long getId() {
		return this.id;
	}

	@Index(suffix = "0")
	@Column(name = "NAME", nullable = false)
	@Documentation("NAME")
	public String getName() {
		return this.name;
	}

	@ManyToOne(fetch = LAZY)
	@NotNull
	@JoinColumn(name = "COD_WORKFLOW", nullable = false)
	@Documentation("WORKFLOW ID")
	public Workflow getWorkflow() {
		return this.workflow;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setWorkflow(Workflow workflow) {
		this.workflow = workflow;
	}

	@Override
	public String toString() {
		return this.getName();
	}
}
